#ifndef SHOGIPLAYER_H_INCLUDED
#define SHOGIPLAYER_H_INCLUDED

#include <QTcpSocket>
#include <QByteArray>
#include <QDataStream>

#include "../common/shogidef.h"
#include "../common/shogicommand.h"
#include "shogistate.h"
#include "shogiregistry.h"

class ShogiState;


class ShogiPlayer : public QObject
{
	Q_OBJECT
public:
	ShogiPlayer(Player p);
	bool assignSocket(QTcpSocket* pSocket);
	bool hasSocketAssigned() const { return (m_pSocket != NULL); }
	QTcpSocket* getSocket() { return m_pSocket;	}

	GameState getGameState() const { return m_state.getCurrentState();}
	ShogiState* getStateObject()  {return &m_state;}

public slots:
	void forceStateChange(GameState s);
	void readIncomingData();
	

protected:
	void receivedCommand(); 


private:
	Player	   m_player;
	ShogiState m_state;


	// Communication 
	QByteArray m_incomingData;
	QTcpSocket* m_pSocket;


};

#endif // SHOGIPLAYER_H_INCLUDED

